/* -----------------------------------------------------------------------
 * test isGameOver
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

int main() {
// based off of testUpdateCoins  example provided for class
    //int i;
    int seed = 1000;
    int numPlayer = 2;

	int r;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;


	int failed = 0;

	
	memset(&G, 23, sizeof(struct gameState));   // clear the game state
	r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
	
	//check gainCard fail for card not in supply
	if(0 != isGameOver(&G)){
		failed = 1;
		printf("Unittest 3 fail: game over at start\n");
	}
	
	//check game end at province empty
	G.supplyCount[province] = 0;
	if(1 != isGameOver(&G)){
		failed = 1;
		printf("Unittest 3 fail: Province empty Game not over\n");
	}

	//check game empty with one supply	
	G.supplyCount[province] = 1; //make sure province not empty
	G.supplyCount[feast] = 0;
	if(0 != isGameOver(&G)){
		failed = 1;
		printf("Unittest 3 fail: one empty Game over\n");
	}
	
	//check game over with two empty supply
	G.supplyCount[duchy] = 0;
	if(0 != isGameOver(&G)){
		failed = 1;
		printf("Unittest 3 fail: only two empty supply Game  over\n");
	}
	
	//check game over with three empty supply
	G.supplyCount[gold] = 0;
	if(1 != isGameOver(&G)){
		failed = 1;
		printf("Unittest 3 fail: three empty supply Game not  over\n");
	}
	
	//check game over with four empty supply
	G.supplyCount[silver] = 0;
	if(1 != isGameOver(&G)){
		failed = 1;
		printf("Unittest 3 fail: four empty supply Game not  over\n");
	}

	if(failed == 0){
		printf("unittest3: isGameOver - All tests passed!\n");
	}
    return 0;
}